﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entities;
using BUS;
using DAL;

public partial class Administrator_loaisp_Update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            load_data();
        }
    }
    private void load_data()
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        Tbl_LoaiSP_Entities loai = Tbl_LoaiSP_BUS.GetByID(id);

        txt_MaLoai.Text =  loai.MaLoai.ToString();
        txt_TenLoai.Text = loai.TenLoai;
        HiddenField1.Value = loai.STT.ToString();
    }

    protected void btn_Up_Click(object sender, EventArgs e)
    {
        Tbl_LoaiSP_Entities loai = Tbl_LoaiSP_BUS.GetByID(int.Parse(HiddenField1.Value));
        loai.MaLoai = txt_MaLoai.Text;
        loai.TenLoai = txt_TenLoai.Text;

        Tbl_LoaiSP_BUS.Update(loai);
        Literal1.Text = "Cập nhật thành công";
        btn_Up.Visible = false;
        HyperLink1.Text = "Về lại trang Danh Sách Loại Sản Phẩm";
        HyperLink1.Visible = true;
        HyperLink1.NavigateUrl = "~/Administrator/loaisp.aspx";

    }
}
